package com.ias.agdis_r.util.flight;

import java.util.Locale;

import com.ias.agdis_r.R;
import com.ias.agdis_r.util.DrawableResourceUtil;
import com.ias.agdis_r.util.S;

public class AirlineCompanyUtil {

	/** 资源不存在时默认ID */
	public static final int DEFALUT_ICON_ID = R.drawable.airplan_default;

	/** Drawable下图片资源中航空公司图标对应的id前缀 */
	private static final String AIRLINE_COMPANY_ICON_FIELD_PRE = "airline_company_icon_";

	/**
	 * 通过航班号获得对应航空公司的图标ID
	 * 
	 * @param context
	 * @param flightNumber
	 * @return
	 */
	public static int getArilineCompanyIconResourceId(String flightNumber) {

		if (S.isEmpty(flightNumber) || flightNumber.length() < 2) {
			return DEFALUT_ICON_ID;
		}

		String fieldName = AIRLINE_COMPANY_ICON_FIELD_PRE
				+ flightNumber.substring(0, 2).toLowerCase(Locale.US);

		return DrawableResourceUtil.getDrawableResourceIdByFieldName(fieldName,
				DEFALUT_ICON_ID);

	}

	/**
	 * 工具类不实例化
	 */
	private AirlineCompanyUtil() {
	}

}
